package com.dankegongyu.component.jsbridge.sdk;

import android.app.Application;

import com.tencent.smtt.sdk.QbSdk;

/**
 * Created by Admin on 2018/7/3.
 */

public class DKX5InitManager {

    public interface DKX5Callback {

        void onCoreInitFinished();

        void onViewInitFinished(boolean success);
    }

    public static void initSDK(Application application, DKX5Callback callback) {

        //搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {
            @Override
            public void onViewInitFinished(boolean success) {
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                if (callback != null) {
                    callback.onViewInitFinished(success);
                }
            }

            @Override
            public void onCoreInitFinished() {
                if (callback != null) {
                    callback.onCoreInitFinished();
                }
            }

        };
        //x5内核初始化接口
        QbSdk.initX5Environment(application, cb);

    }


}
